import { fliterPermission } from "@/utils/sys.js";

export const apis = {
  list: `/business/basis/getList?modelCode=MODEL_BUSINESS_NODE&authCode=FUNCTION_NODE_LIST`,
  del: `business/node/del?authCode=BTN_NODE_DEL`,
  add: `business/node/add?authCode=BTN_NODE_ADD`,
  edit: `business/node/edit?authCode=BTN_NODE_EDIT`,
  detail: `business/basis/detail?modelCode=MODEL_BUSINESS_NODE&authCode=BTN_NODE_DETAIL`,
  getApi: `business/node/getApi?authCode=BTN_NODE_API`,
  api: `business/node/api?authCode=BTN_NODE_API`,
};
export const configs = {
  listUrl: apis.list,
  pageOn: false, // 开启分页
  searchOn: true, // 开启搜索
  operateOn: true, //开启操作区域
  treeOn: false, // 开启树形
  treePropsOn: true, // 树形开启props
  reserveSelection: true,
  defaultExpandAll: false
};

export const searchs = [
  {
    type: "Input",
    column: "node_name",
    label: "节点名称",
  },
  {
    type: "Input",
    column: "code",
    label: "节点编码",
  },
  {
    type: "Select",
    column: "node_type",
    label: "节点类型",
    dimCode: "DIM_TYPE_NODE_TYPE"
  },
];

export const pages = {
  pageSize: 20,
  orders: [
    {
      field: "id",
      sort: "desc",
    },
  ],
};
export const columns = [
  { type: "selection" },
  
  {
    label: "节点名称",
    column: "node_name",
  },
  {
    label: "节点描述",
    column: "node_desc",
  },
  {
    label: "节点编码",
    column: "code",
  },
  {
    label: "节点类型",
    column: "node_type",
    display: "dim",
    slot:'nodeType'
  },
  {
    label: "更新时间",
    column: "utime",
    format: "datetime",
  },
  {
    label: "操作",
    column: "operate",
    width: "240",
    fixed: "right",
  },
];

export const buttons = fliterPermission([
  {
    operate: "add",
    text: "新增",
    permission: "BTN_NODE_ADD",
  },
  {
    operate: "deleteAll",
    text: "删除",
    permission: "BTN_NODE_DEL",
    type: 'danger'
  },
])
export const columnButtons = fliterPermission([
  {
    operate: "detail",
    text: "详情",
    permission: "BTN_NODE_DETAIL",
  },
  {
    operate: "edit",
    text: "编辑",
    permission: "BTN_NODE_EDIT",
  },
  {
    operate: "delete",
    text: "删除",
    permission: "BTN_NODE_DEL",
    type: 'danger'
  },
  {
    operate: "api",
    text: "接口分配",
    permission: "BTN_NODE_API",
    hidden: ({ row })=> {
      if(['3','4'].includes(row.node_type)){
        return false
      }
      return true
    },
  },
]);
